﻿Public Class ThueThuNhapCaNhanForm
    Dim NguoiPhuThuoc As Integer
    Dim TienMienGiam As Double
    Dim Nam As Integer
    Dim SoTien As Double
    Dim dt As DataTable
    Private Sub Button2_Click_1(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Me.Dispose()
    End Sub

    Private Sub btTinh_Click(sender As System.Object, e As System.EventArgs) Handles btTinh.Click
        If txtNguoiPhuThuoc.Text.Trim().Length = 0 Then
            MessageBox.Show("Xin vui lòng điền người phụ thuộc")
        End If
        If txtTienMienGiam.Text.Trim().Length = 0 Then
            MessageBox.Show("Xin vui lòng điền tiền miễn giảm")
        End If
        If txtSoTien.Text.Trim().Length = 0 Then
            MessageBox.Show("Xin vui lòng điền số tiền cần tính")
        End If
        Integer.TryParse(txtNguoiPhuThuoc.Text, NguoiPhuThuoc)
        Double.TryParse(txtTienMienGiam.Text, TienMienGiam)
        Double.TryParse(txtSoTien.Text, SoTien)

        Dim TienThue As Double = ThueThuNhapCaNhanBUS.TinhThue(SoTien, NguoiPhuThuoc, TienMienGiam)
        If TienThue < 0 Then
            lbTienThue.Text = "0 VND"
        Else
            lbTienThue.Text = TienThue.ToString("###,###,### VND")
        End If
    End Sub

    Private Sub ThueThuNhapCaNhanForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtTienMienGiam.Text = 3600000
        txtNguoiPhuThuoc.Text = 0
        dt = QuanLyThuBUS.TongTien(MainForm.current_user.MaUser)
        cbNam.DataSource = dt
        cbNam.DisplayMember = "Nam"
        cbNam.ValueMember = "Nam"
    End Sub

    Private Sub cbNam_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cbNam.SelectedIndexChanged
        If cbNam.SelectedIndex >= 0 Then
            txtSoTien.Text = dt.Rows(cbNam.SelectedIndex)("SoTien").ToString()
        End If
    End Sub
End Class